package com.example.mobile2021606144ywr0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText edtMainAccout;
    private EditText edtMainPsw;
    private Button btnMainLogin;
    private Button btnMainResert;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            String account=edtMainAccout.getText().toString();
            String password=edtMainPsw.getText().toString();

            if (account.length()==0) {
                Log.i("登录", "请输入用户名");
            }else if (password.length()==0) {
                Log.i("登录", "请输入密码");
            }else {

                if (account.equals("admin") & password.equals("123456")) {
                    Log.i("登录", "登录成功");
                } else {
                    Log.i("登录", "登录失败");
                }
                edtMainAccout.setText(null);
                edtMainPsw.setText(null);
            }
            }
        });
        btnMainResert.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edtMainPsw.getText().toString();
                edtMainAccout.getText().toString();
            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        edtMainAccout = (EditText) findViewById(R.id.edt_main_accout);
        edtMainPsw = (EditText) findViewById(R.id.edt_main_psw);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainResert = (Button) findViewById(R.id.btn_main_resert);
    }
}